package shuishijie.suishijie.model;

import android.text.TextUtils;

/**
 * Created by mindx on 2017/8/29.
 */

public class GoodsInfo {
//    /**
//     * 商品id
//     **/
//    public int goods_id;
    /**
     * 商品图片
     **/
    private String goodsImgPath;
//    /**
//     * 商品名
//     **/
//    public String goodsName;
    /**
     * 商品价格
     **/
    private float goodsPrice;
//    /**
//     * 可赚钱数
//     **/
//    public float profit;
//    /**
//     * "在卖"人数
//     **/
//    public int account;


    /**
     * 商品名
     **/
    public String goodsName;
    /**
     * 标签
     **/
    public String tag;
    /**
     * 商品售价
     **/
    private float discountPrice;
    /**
     * 市场价
     **/
    public float marketPrice;
    /**
     * 利润
     **/
    public float profit;
    /**
     * 积分
     **/
    public int integral;
    /**
     * "在卖"人数
     **/
    private int account;
    private int sharePerson;    // 只有营销活动-商品列表接口返回的参数叫 sharePerson，其他接口都是account

    public int getSharePerson() {
        return account > 0 ? account : sharePerson;
    }

    public void setSharePerson(int sharePerson) {
        if (sharePerson < 0) {
            sharePerson = 0;
        }
        this.sharePerson = sharePerson;
        this.account = sharePerson;
    }

    public int getTotalStorage() {
        return totalStorage;
    }

    /**
     * 总库存
     **/
    private int totalStorage = Integer.MAX_VALUE;
    /**
     * 商品ID
     **/
    public int goods_id;
    /**
     * 商品图片
     **/
    private String path;
    /**
     * 店铺收藏表id
     **/
    private int shopgoods_id = 0;
    private int id = 0;      // 在我的店铺接口中，返回的叫id。  /shop/showShopGoodsList.json
    /**
     * 当前页码
     **/
    public int currentPage;
    /**
     * 总页码
     **/
    public int totalPage;

    /**
     * 业务逻辑变量
     */
    public boolean myShop = false;
    public boolean shopPreview;

    public void setGoodsImgPath(String goodsImgPath) {
        this.goodsImgPath = goodsImgPath;
    }

    public String getPicturePath() {
        return TextUtils.isEmpty(goodsImgPath) ? path : goodsImgPath;
    }

    public void setGoodsPrice(float goodsPrice) {
        this.goodsPrice = goodsPrice;
    }

    public float getGoodsPrice() {
        return goodsPrice > 0 ? goodsPrice : discountPrice;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj != null && obj instanceof GoodsInfo) {
            return goods_id == ((GoodsInfo) obj).goods_id;
        }
        return super.equals(obj);
    }

    public int getShopgoods_id() {
        return shopgoods_id > 0 ? shopgoods_id : id;
    }

    public void setShopgoods_id(int shopgoods_id) {
        this.id = shopgoods_id;
        this.shopgoods_id = shopgoods_id;
    }

    public void setId(int id) {
        this.id = id;
    }

    String shareURL;

    public String getShareURL() {
        return shareURL;
    }

    public void setShareURL(String shareURL) {
        this.shareURL = shareURL;
    }

}
